<?php
namespace app\admin\controller;

use think\Controller;

use app\admin\controller\Base;

use think\Db;
use think\Session;

class User extends Base
{
    public function lst()
    {
        $user_lst=db('user')->select();
        $this->assign('info',$user_lst);
        return $this->fetch();
    }
    
    public function edit()
    {
        $c_id=input('user_id');
        $c_info=db('user')->where('user_id',$c_id)->select();
        $this->assign('info',$c_info);
        return $this->fetch();
    }
   
   
    public function doedit()
    {
        $user_id=input('user_id');
        // if(request()->isPost()){
                $data=[
                   'user_phone'=>input('user_phone'),
                   'user_date'=>input('user_date'),
                ];
                $res=db('user')->where('user_id',$user_id)->update($data);
                if($res){
                    $this->success('修改用户信息成功！','lst');
                }else{
                    $this->error('修改用户信息失败...');
                }
            // }
        }

    public function modify()//冻结用户
    {
        $user_id=input('user_id');
        $user_status=db('user')->where('user_id',$user_id)->field('user_status')->find();
        if($user_status['user_status']==0||$user_status['user_status']==2||$user_status['user_status']==3)
        {
            $user_statusl=['user_status'=>1];
            $res=db('user')->where("user_id",$user_id)->update($user_statusl);
            if($res)
            {
                return $this->success('冻结用户成功！','lst');//跳转到用户列表页
            }
            else{
                return $this->error('冻结用户失败!');
        }
        }
        else if($user_status['user_status']==1){
            $user_statusl=['user_status'=>0];
        
            $res=db('user')->where("user_id",$user_id)->update($user_statusl);
            if($res)
            {
                return $this->success('解封用户成功！','lst');//跳转到用户列表
            }
            else{
                return $this->error('解封用户失败!');
        }
        }
    }
   
}